#ifndef ITEM_CPP_
#define ITEM_CPP_

#include "Item.h"
unsigned int Item::lastItemID = 110204000;

bool Item::operator==(const Item & item2) const {
	return ((this->getID() == item2.getID())
			&& (this->getName() == item2.getName())
			&& (this->getItemType() == item2.getItemType())
			&& (this->getOwner() == item2.getOwner())
			&& (this->getAge() == item2.getAge())
			&& (this->getPrice() == item2.getPrice()));
}

bool Item::operator< (const Item & item2) const {
	return ((this->getName() < item2.getName())
			|| ((this->getName() == item2.getName())
				&& (this->getItemType() < item2.getItemType()))
			|| ((this->getName() == item2.getName())
					&& (this->getItemType() == item2.getItemType())
					&& (this->getAge() < item2.getAge())));
}

void Item::updatePrice(int quant) {
	int itemYear = age.get_year();

	float percentage = (itemYear)/1000;

	if(quant > 1) {
		percentage /= quant;
	}

	price *= percentage;
}

void Item::showItem() const{

	cout << "ID: " << itemID << endl;
	cout << "Name: " << itemName << endl;

	string _maintype = itemType.getMaintype();
	if(_maintype == "NULL")
	{
		cout << "Maintype: None" << endl;
	}else
	{
		cout << "Maintype: " << _maintype << endl;
	}

	string _subtype = itemType.getSubtype();
	if(_subtype == "NULL")
	{
		cout << "Subtype: None" << endl;
	} else
	{
		cout << "Subtype: " << _subtype << endl;
	}

	if (owner == "NULL") {
		cout << "No owner" << endl;
	} else {
		cout << "Owner ID: " << owner << endl;
	}

	cout << "Crafting Date: ";
	age.displayDate();
	cout << endl;

	cout << "Date of the last operation made on this item: ";
	last_operation.displayDate();
	cout << endl;

	cout << "Price: " << price << endl;

	cout << "------------------------------------------------------------" << endl;
}

#endif /* ITEM_CPP_ */
